
	<table id="data"></table>
	<div id="bombBox"></div>

	<script type="text/javascript">
		
		(function($){

			setTimeout("data()",100); 
		})(jQuery);

		// 数据查询
		function data(){

			$('#data').datagrid({    
		    	url:'/daoOwners/ownersJsonSeleft',
				method:'post',
				fit:true,
				fitColumns:true,
				striped:true,
				border:false,
				pagination:true,
				rownumbers:false,
				toolbar:'#query',
				singleSelect:true,
				pageSize:30,//每页显示的记录条数，默认为10 
		        pageList:[10,20,30,40,50,500,1000],//可以设置每页记录条数的列表 
			    columns:[[
			    	 {field:'id',title:'id',width:20,align:'center'},	    	 
					 {field:'phone',title:'手机号',width:40,align:'center',},
					 {field:'accounts',title:'帐号',width:40,align:'center'},
					 {field:'nickname',title:'昵称',width:40,align:'center'},
					 {field:'fullName',title:'姓名',width:40,align:'center'},
					 {field:'headPortrait',title:'头像',width:40,align:'center',
					 	formatter:function(value, row, index){
					 		var headPortrait = jQuery.parseJSON(row.headPortrait);
					 		if( headPortrait[0] == undefined || headPortrait[0] == '' ){
					 			return "";
					 		} else {
					 			return "<a target='_blank' href='"+headPortrait[0].firstPictureAddress+"'><img width='100' height='100' src='"+headPortrait[0].firstPictureAddress+"' alt=''></a>";
					 		}
					 	}
					 },
					 {field:'eMail',title:'邮箱',width:40,align:'center'},
					 {field:'createTime',title:'创建时间',width:40,align:'center'},
					 {field:'operation',title:'操作',width:20,align : 'center', 
						 formatter:function(value,row,index){
						 	var id= row.id; 
							var str = ""
								    + "<button class='btn btn-default btn-xs' style='margin:2px;' onClick='saveStatus("+id+","+-100+")'>删除</button>"
							return str;
						 }
					 }
			    ]],
				onLoadError:function(info){

				},
				onLoadSuccess:function(info){

					// setTimeout("doAdd()",10);
				},
				
			});  

			var p = $('#data').datagrid('getPager'); 
		    $(p).pagination({ 
		        beforePageText:'第',//页数文本框前显示的汉字 
		        afterPageText:'页 共 {pages} 页', 
		        displayMsg:'当前显示 {from} - {to} 条记录 共 {total} 条记录', 
				buttons:[{
					iconCls:'icon-add',
					handler:function(){
						// doAdd();
						seeS();
					}
				},'-',{
					iconCls:'icon-help',
					handler:function(){
						alert('help');
					}
				}]
		    }); 
		} 

		// 状态更新
		function saveStatus(id, num){

			$.messager.confirm('确认','您确认想要执行吗？',function(r){    
				if(r){
			    	$.messager.progress({msg:'正在执行...',interval:3000,});
					$.ajax({
						type: "post",
						url: "/daoOwners/ownersSaveStatus",
						data:{
							id:id,
							num:num,
						},
						cache: false,
						dataType:'html',
						success: function(data){
							var data = eval('('+data+')');
							if( data.info == 'success' ){
								
								$.messager.progress('close');
								$('#action').dialog('close');
								$('#data').datagrid('reload');   
							} else {
								
								$.messager.progress('close');
								$.messager.alert('提示信息', data.info);
							}
						}
					});
				}
			});
		}

		// 数据更新
		function saveData(id){

			$.messager.progress({msg:'正在查询...',interval:3000,});
			$.ajax({
				type:"post",
				url:"/daoUsers/usersIdSelect",
				data:{
					id:id,
				},
				cache: false,
				dataType:'html',
				success:function(data){

					var data = eval('('+data+')');
					if( data.info != 'success' ){
						
						$.messager.progress('close');
						$.messager.alert('提示信息', data.info);
					} else {
						
						$.messager.progress('close');
						doAdd(id, data.rows);
					}
				}
			});
		}

		// 父窗口关闭弹框方法
        function parentWindowClosed() {
        	
            $("#bombBox").dialog("close");
            $('#data').datagrid('reload');   
        }

		// 弹框方法
		function seeS(id){

			var url = '/adminUsers/adminUsersAddOwners';
			var content = '<iframe id="iframeBombBox" scrolling="auto" frameborder="0" src="'
						+ url + '" style="width:100%;height:100%;"></iframe>';
			$('#bombBox').dialog({
			    title: '用户',
			    width: '100%',
			    height: '100%',
			    modal: true,
			    content: content,
			    scroll: false,
			}); 
		}

	</script>
